class Person {
  name: string
  age: number
  constructor(name: string, age: number) {  //初始化
    this.name = name
    this.age = age
  }
  eating() {
    console.log('parent eating');
  }
}

class Student extends Person{
  sno: number
  constructor(name: string, age: number, sno: number) { //2.类里面自动调用constructor函数 把传来的值赋值给当前 
    super(name, age)   //3.继承类使用 super调用父类的构造器
    this.sno = sno
  }
  studying() {
    console.log('studing');
  }

  eating() {  //4.方法重写 不满意父类的方法
    super.eating()  //5.也可以再使用super调用父类的方法
    console.log("student eating");
  }
}
const stu = new Student("yzh", 18, 1804515) //1.创建实例对象时 需要传入初始化值
console.log(stu.name);
console.log(stu.age);
console.log(stu.sno);
stu.studying()
stu.eating()














export {}